﻿class Student
{
    public string Name { get; set; }
    public string Id { get; set; }

    public Student(string name, string id)
    {
        Name = name;
        Id = id;
    }
}
using System.Collections.Generic;

class Class
{
   
    private List<Student> students = new List<Student>();
    public void AddStudent(Student student)
    {
        students.Add(student);
    }
    public Student this[int index]
    {
        get
        {
            if (index < 0 || index >= students.Count)
            {
                throw new IndexOutOfRangeException("索引超出范围");
            }
            return students[index];
        }
    }
}